package de.acagamics.roteschlupfmuetze.io;

import java.io.*;  
import java.beans.*;

/**
 * @author Enrico Gebert
 *
 */
public class XMLDataReader<T> {

	@SuppressWarnings("unchecked")
	public T readXMLData(String filename) {
		// Deserialize 
		T result = null;
	    XMLDecoder dec = null; 
		
	    try /*( XMLDecoder dec = new XMLDecoder( new FileInputStream(filename)))*/
	    { 
	      dec = new XMLDecoder( new FileInputStream(filename));
	      result = (T) dec.readObject(); 
	    } 
	    catch ( IOException e ) { 
	      e.printStackTrace(); 
	    }
	    catch ( ClassCastException e) {
	    	e.printStackTrace();
	    }
	    finally { 
		      if ( dec != null ) 
		        dec.close(); 
		    }
	    return result;
	}
}

